package com.ang.transaction.service.impl;

import com.ang.transaction.mapper.ClassMapper;
import com.ang.transaction.mapper.UserMapper;
import com.ang.transaction.model.TClassModel;
import com.ang.transaction.model.TUserModel;
import com.ang.transaction.service.ITestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TestServiceImpl implements ITestService {
    @Autowired
    UserMapper userMapper;

    @Autowired
    ClassMapper classMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void test() {
        TUserModel userModel = new TUserModel();
        userModel.setName("张三");
        userModel.setAge(28);

        userMapper.insert(userModel);
        test1();
    }


    public void test1(){
        TClassModel classModel = new TClassModel();
        classModel.setName("三年一班");

        classMapper.insert(classModel);
        int i = 1/0;
    }
}
